In [1]:
import numpy as np
import pandas as pd
import math
import cmath
from scipy.optimize import root
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
archivo_de_datos = ("Table1.txt")
archivo_de_datos
Out[2]:
In [ ]:
In [3]:
c1 = np.linspace(1157 - 112, 1157 + 112, 10)
c1
Out[3]:
In [10]:
class InterfazPolimero2:
def __init__ (self, archivo_de_datos, c1):
self.archivo_de_datos = archivo_de_datos
self.c1 = c1
def leerDatos(self):
self.datos = pd.read_csv(self.a,sep=" ")
self.valoresDatos = self.datos.values
return self.datos
def asignarParametros(self):
self.Experiment = self.valoresDatos[:,0]
self.Thickness = self.valoresDatos[:,1]
self.FoodSimulant = self.valoresDatos[:,2]
self.Cpo = self.valoresDatos[:,3]
self.K = self.valoresDatos[:,4]
self.Dp = self.valoresDatos[:,5]
self.RMSE = self.valoresDatos[:,6]
self.k = self.valoresDatos[:,7]
self.c4 = self.valoresDatos[:,8]
def inicializarC2(self):
self.c2 = np.zeros(10)
self.dimension = np.shape(self.c2)
print(self.dimension)
return self.c2
def calcul(self):
self.j1 = (self.Dp / (self.Thickness / 2)) * ( self.c1 - self.c2)
self.c3 = self.c2 / self.K
self.j2 = self.k * (self.c3 - self.c4)
return (self.j1 - self.j2) / self.j1
In [ ]:
In [11]:
class InterfazPolimero:
def __init__ (self,a):
self.a=a
self.c1 = np.linspace(1157-112,1157+112,10)
def lire(self):
tab = pd.read_csv(self.a,sep=" ")
coef =tab.values
self.Experiment = coef[:,0]
self.Thickness = coef[:,1]
self.FoodSimulant = coef[:,2]
self.Cpo = coef[:,3]
self.K = coef [:,4]
self.Dp = coef[:,5]
self.RMSE = coef[:,6]
self.k = coef[:,7]
self.c4 = coef[:,8]
return tab
# self.c1 = np.linspace(1157-112,1157+112,10)
self.D = self.Dp
self.L = self.Thickness
self.K1 = self.K
# self.c4 = 0.05
# self.k = 7.14e-6
self.c2 = np.zeros(10)
dimension = np.shape(self.c2)
try:
calcul(self,c2,D,k,K,c4,c1,L)
except:
def calcul(self,c2,D,k,K,c4,c1,L):
self.j1 = ((float(self.Dp)/(float(self.Thickness)/2))*(float(self.c1)-float(self.c2)))
self.c3 = float(self.c2)/float(self.K)
self.j2 = float(self.k)*(float(self.c3)-float(self.c4))
return (j1-j2)/j1
def calcul2(self):
i = 0
for self.c1i in self.c1:
for self.Dpi in self.Dp:
for self.ki in self.k:
for self.Ki in self.K:
for self.Thicknessi in self.Thickness:
sol = root(calcul,15,args=(float(self.Dp),float(self.k),float(self.K),float(self.c4),float(self.c1),float(self.Thickness)))
c2[i]= sol.x
i = i+ 1
return c2
In [12]:
p = InterfazPolimero("Table1.txt")
p
Out[12]:
In [14]:
p.lire()
Out[14]:
In [15]:
p.calcul2()
In [16]:
c1 = np.linspace(1157-112,1157+112,10)
K = 0.1
c4 = 0.05
k = 7.14e-6
D = 1.93e-13
L = 1
c2 = np.zeros(10)
dimension = np.shape(c2)
def calcul(c2,D,k,K,c4,c1,L):
j1 = (D/(L/2)*(c1-c2))
c3 = c2/K
j2 = k*(c3-c4)
return (j1-j2)/j1
def calcul2():
i = 0
for c1i in c1:
sol = root(calcul,15,args=(D,k,K,c4,c1,L))
c2[i]= sol.x
i = i + 1
return c2
In [17]:
calcul2()
Out[17]:
In [18]:
a =np.linspace(1,11,10)
a
Out[18]:
In [19]:
b = np.zeros(10)
for ai in a:
b = ai + 1
In [20]:
b
Out[20]:
In [21]:
class InterfazPolimero:
def __init__ (self,a):
self.a=a
self.c1 = np.linspace(1157-112,1157+112,10)
def lire(self):
tab = pd.read_csv(self.a,sep=" ")
coef =tab.values
self.Experiment = coef[:,0]
self.Thickness = coef[:,1]
self.FoodSimulant = coef[:,2]
self.Cpo = coef[:,3]
self.K = coef [:,4]
self.Dp = coef[:,5]
self.RMSE = coef[:,6]
self.k = coef[:,7]
self.c4 = coef[:,8]
return tab
In [22]:
p.lire()
Out[22]:
In [ ]: